<%--
 *  File:    DistributortenderProdDetailInfo.jsp
 *  @Author: Saraxia
 *  Date:    2013/03/25
 *
 *  Copyright (C) 2000 - 2012 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<% //--------------------------------------  setting logger --%>


<% //--------------------------------------  variant and initialization --%>
<%
    Category cat = Category.getInstance("jsp.DistributortenderProdDetailInfo");
	String strModuleName = "CM";
 	String strTableName = "v_batchcustomermap";
 	//String privilegeCode = "A0908";   
    String contextPath = request.getContextPath(); 
%>

<% //--------------------------------------  include files list --%>

<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<%@ include file="/rpt/ReportURL.inc"%>

<html>
<iframe name="summaryfrm" scrolling="no" frameborder="0"
	style="position:absolute; top:0px; left:0px; display:none;border:#909eff 1px solid;"></iframe>
<head>
<title>DistributortenderProdDetailInfo</title>
<PageFlow:CheckPageFlow pageName="p_disprod"/>
<%

    Vector searchresults = (Vector)pageContext.getAttribute("searchresults");
    if(searchresults == null)
    {
    	searchresults = new Vector();
    }
  	
	//HashMap userinfo = (HashMap)session.getAttribute("userinfo");
	//if(userinfo == null) userinfo = new HashMap();
	
	//Integer distributortenderid =  (Integer)pageContext.getAttribute("distributortenderid");
	
	
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../js/FuncLib.js"></script>
<script language="JavaScript" src="../../js/ScriptLib.js"></script>
<%@ include file="../../inc/SummaryDivision.inc" %>
<iframe name="reloadHandler" style="display:none" ></iframe>
<%@ include file ="/inc/NewCalendar.inc" %>

<% //--------------------------------------  output variant from pageflow --%>

<script language="JavaScript" >

function page_summary(actionvalue,orderbyname){
  	 var editform = summaryPrepare(cform,actionvalue,orderbyname);
  	 var allcheckbox = document.cform.allcheckbox.checked;
  	 if(allcheckbox){
  	  	 cform.flag.value=1;
  	  	 var flag=cform.flag.value;
  	 }
  	 else{
  	  	 cform.flag.value=0;
  	  	 var flag=cform.flag.value;
  	 }
 	 editform.action = "DistributortenderProdDetailInfo.jsp?<%= OvalTools.randomURL() %>";
 	 editform.target = "_self";
 	 isRunning = true;
 	 editform.submit();
}

function page_add(){
	if(!checkForm(document.cform)) return;
	
    var myform = eval("document.cform");
	var istender=myform.istender.value;
	if(istender!=null && istender==1)
	{
		var tenderdate=myform.tenderdate.value;
		var purchasebegindate=myform.purchasebegindate.value;
		var purchaseenddate=myform.purchaseenddate.value;
		var tenderprice=myform.tenderprice.value;
		if(tenderdate==""){
			alert("请选择中标时间");
			myform.tenderdate.select();
			return ;
		}
		if(purchasebegindate==""){
			alert("请选择采购开始时间");
			myform.purchasebegindate.select();
			return ;
		}
		if(purchaseenddate==""){
			alert("请选择采购结束时间");
			myform.purchaseenddate.select();
			return ;
		}
		if(tenderprice==""){
			alert("请填写中标价格");
			myform.tenderprice.select();
			return ;
		}
	}


	var objnumber=myform.tenderprice;
	if(objnumber!=null && !isNumeric(objnumber.value))
	{
		alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER_TYPE",label.getLabelName("L_TenderPrice"))%>");
		myform.tenderprice.select();
		return;
	}
	var objnumber1=myform.historytenderprice;
	if(objnumber1!=null && !isNumeric(objnumber1.value))
	{
		alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER_TYPE",label.getLabelName("L_HistoryTenderPrice"))%>");
		myform.historytenderprice.select();
		return;
	}
	var objnumber2=myform.bidprice;
	if(objnumber2!=null && !isNumeric(objnumber2.value))
	{
		alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER_TYPE",label.getLabelName("L_BidPrice"))%>");
		myform.historytenderprice.select();
		return;
	} 
			
	 emptyToNull(document.cform);
	 cform.actionname.value = "add";
  	 cform.target = "_self";
  	 isRunning = true;
  	 cform.submit();
}


function page_save(){
	
	//if (!checkForm(document.cform)) return;
	
    var myform = eval("document.cform");
	for(i=0;i<Number(myform.numrows.value);i++)
	{
		var tendername=eval("myform.tendername"+i).value;
		var objnumber=eval("myform.tenderprice"+i);
		if(tendername=="是")
		{
			if(objnumber.value==""){
				alert("请填写中标价格");
				eval("myform.tenderprice"+i).select();
				return;
			}
		}
		
		if(objnumber!=null && !isNumeric(objnumber.value))
		{
			alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER_TYPE",label.getLabelName("L_TenderPrice"))%>");
			eval("myform.tenderprice"+i).select();
			return;
		}
		var objnumber1=eval("myform.historytenderprice"+i);
		if(objnumber1!=null && !isNumeric(objnumber1.value))
		{
			alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER_TYPE",label.getLabelName("L_HistoryTenderPrice"))%>");
			eval("myform.historytenderprice"+i).select();
			return;
		}
		var objnumber2=eval("myform.bidprice"+i);
		if(objnumber2!=null && !isNumeric(objnumber2.value))
		{
			alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER_TYPE",label.getLabelName("L_BidPrice"))%>");
			eval("myform.historytenderprice"+i).select();
			return;
		}

				
			
	}
	emptyToNull(document.cform);
	cform.actionname.value = "save";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
}

function page_delete(){
    if(isNullChecked(cform.deleteids))
    {
        alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>");
        return;
    }
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>")) return;
    
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
}

function allcheckselect(){
	var allcheck = cform.allcheck.checked;
	var alldatafile = document.getElementsByName('deleteids');
	var length = alldatafile.length;
	if(allcheck){
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = true;
		}
	}else{
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = false;
		}	
	}
}



function page_return(){
	parent.location.href = "DistributortenderSummary.jsp?<%= OvalTools.randomURL() %>";
}

function page_price(){
	
	var myform = eval("document.cform");
	for(i=0;i<Number(myform.numrows.value);i++)
	{
		var objnumber=eval("myform.tenderprice"+i).value;
		var ntspricenumber=eval("myform.ntsprice"+i).value;
		var ratenumber=(Number(objnumber)/Number(ntspricenumber));
		ratenumber = Math.round(ratenumber*100);
		eval("myform.rate"+i).value=ratenumber;
	}
}

page_price();



function page_setItem(id, buyeritemcode, name, umcode, umname,prdocname,listprice,taxrate,islotcontrol, costprice,prodid,selleritemcode,attricod,piece,prdn,spec,zmycontentspec)
{
     cform.prodid.value = prodid;
     cform.prodcode.value = buyeritemcode;
     cform.prodname.value = name;
    if (popwindow != null) popwindow.close();
  //returnwarehouseandprice("","",obj[0].value,"120.00","CNY",umcode,"100");
}

function page_setProduct(id,code,name,price,spec){	
	if(switchtype==3){
		cform.serproductid.value=id;
		cform.serproductcode.value=code;
		cform.serproductname.value=name;
	}else if(switchtype==6){
		cform.prodid.value=id;
		cform.prodcode.value=code;
		cform.prodname.value=name;
	}
	hiddenFrm();
}

var isHidden;
function frm_select(e,flag){
	switchtype=flag;
	isHidden = "block";
	var productgroupid=cform.productgroupid.value;
	var _target = getPosition(e);
    var _obj = document.getElementById("summaryfrm");
    _obj.style.left = _target.x;
    _obj.style.top = _target.y + e.clientHeight;
    _obj.style.height="250px";
    _obj.style.width="530px";
    _obj.style.zIndex = 5000;
    _obj.style.display = "block";
	var strUrl = "";	
	if(flag==1 || flag==4){
		strUrl = "<%=contextPath %>/tdr/datatypein/OrgSelectPop.jsp?maxitem=8&globalpccode=1&<%= OvalTools.randomURL() %>";
	}else if(flag==2 || flag==5){
		if(flag==5)_obj.style.left = _target.x-530;
		strUrl = "<%=contextPath %>/tdr/datatypein/OrgSelectPop.jsp?maxitem=8&globalpccode=2&<%= OvalTools.randomURL() %>";
	}else if(flag==3 || flag==6){
		_obj.style.height="300px";
		strUrl = "<%=contextPath %>/tdr/datatypein/ProdSelectPop.jsp?maxitem=10&<%= OvalTools.randomURL() %>"+"&productgroupid="+productgroupid;
	}
    document.summaryfrm.location.href = strUrl;
}
function getPosition(e) {
        var left = 0;
        var top = 0;
        while (e.offsetParent) {
            left += e.offsetLeft + (e.curentStyle? (parseInt(e.curentStyle.borderLeftWidth).NaN0()):0);
            top += e.offsetTop + (e.curentStyle ? (parseInt(e.curentStyle.borderTopWidth)).NaN0() : 0);
            e = e.offsetParent;
        }
        left += e.offsetLeft + (e.curentStyle ? (parseInt(e.curentStyle.borderLeftWidth)).NaN0() : 0);
        top += e.offsetTop + (e.curentStyle ? (parseInt(e.curentStyle.borderTopWidth)).NaN0() : 0);
        return {x:left, y:top};
}





function hiddenFrm(){
	document.getElementById("summaryfrm").style.display = "none";
}

</script>

</head>
<body onload="page_price();">
<%-- //--------------------------------------  page location --%>

<form name="cform" method="post" action="<%=contextPath %>/Dispatcher"  target="_self">
    <custom:hidden property="pagename" value="p_disprod"/>
    <input type="hidden" name="actionname">
	<input type="hidden" name="numrows" value="<%=searchresults.size() %>">
	<custom:hidden property="userid" />
	 <input type="hidden" name="flag" >
	 <custom:hidden property="productgroupid"/>
     <custom:hidden property="parentorgid"/>
     <custom:hidden property="datacategory"/>
     <custom:hidden property="globalpccode"/>
    <custom:hidden property="objecttype"   />
    <input type="hidden" name="na" value=" ">
	<table width="100%" cellspacing="0" border="0" cellpadding="0">

	 
	    <tr> 
		    <td> 
		      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" >
		        <tr class="deepblue-left">
		        <!-- 
				  <td width="1%" class="title_center"><input type="checkbox" name="allcheck" class="normalradio" onclick="allcheckselect();"></td>
		          <td class="title_left" width="20%px"><%= label.getLabelName("L_Products") %></td>
		         -->
		          <td width="2%" class="title_center">&nbsp;</td>
                  <td class="title_center" ><%= label.getLabelName("L_ProductCode")%></td>
                  <td class="title_center" width="15%"><%= label.getLabelName("L_ProductName")%></td>
                  <td class="title_center" width="5%"><%= label.getLabelName("L_IsTender")%></td>
                  <td class="title_center" width="5%"><%= label.getLabelName("L_YorN")%><%= label.getLabelName("L_Fulfill")%></td>
                  <td class="title_center" width="5%"><%= label.getLabelName("L_DrugAttribute")%></td>
                  <td class="title_center" width="10%"><%= label.getLabelName("L_TenderTime")%></td>
                  <td class="title_center" width="10%"><%= label.getLabelName("L_Purchase")+label.getLabelName("L_StartTime")%></td>
                  <td class="title_center" width="10%"><%= label.getLabelName("L_Purchase")+label.getLabelName("L_EndTime")%></td>	  		         
		          <td class="title_center" width="8%"><%= label.getLabelName("L_TenderPrice") %><span class="red">*</span></td>
                  <td class="title_center" width="8%"><%= label.getLabelName("L_HistoryTenderPrice") %></td>
                  <td class="title_center" width="8%"><%= label.getLabelName("L_BidPrice") %></td>
                  <td class="title_center" width="8%"><%= label.getLabelName("L_Rate") %></td>	
                  
                   <td class="title_center" width="10%"><%= label.getLabelName("L_Comments") %></td>	
                   	          
		        </tr>
		        <%
	            	int i = 0;
	             	String strClassType = new String();
	          	%>
	        <%
				String distributortenderid = null;
				distributortenderid = (pageContext.getAttribute("distributortenderid")).toString(); 
			%>	          	
		         <logic:iterate id="onerow" collection="<%= searchresults %>" indexId="idx"> 
		           	<%
		            	HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
		            	if(i%2 == 1)
		            	{
		              		strClassType = "td-listrom";
		            	}else{
		              		strClassType = "";
		            	}
		            	i++;
		            	
		          	%>
		          	<tr id="tr<%=idx %>" class="none">
		          		<td id="td" class="title_left" >
		                    <input type="checkbox" name="deleteids" value="<%=JspHelper.filterNull( tempMap.get("distributortenderprodid") )%>" class="checkbox" disabled>
		            		<custom:hidden name="onerow" property="distributortenderprodid" colIndex="<%=idx %>" />
		            	</td>
						<td ><custom:write property="prodcode" name="onerow"/>&nbsp;
						</td>
						<td><custom:write property="prdn" name="onerow"/>&nbsp;
					    </td>
						<td><custom:write property="tendername" name="onerow"/>&nbsp;
							<custom:hidden name="onerow" property="tendername" colIndex="<%=idx %>" />
						</td>
						<td><custom:write property="executename" name="onerow"/>&nbsp;
							<custom:hidden name="onerow" property="executename" colIndex="<%=idx %>" />
						</td>
						<td><custom:write property="drugname" name="onerow"/>&nbsp;
							<custom:hidden name="onerow" property="drugname" colIndex="<%=idx %>" />
						</td>												
						<td><custom:write property="tenderdate" name="onerow"/>&nbsp;
					    </td>
						<td><custom:write property="purchasebegindate" name="onerow"/>&nbsp;
					    </td>
						<td><custom:write property="purchaseenddate" name="onerow"/>&nbsp;
					    </td>						    						    						    					    						           	
						<td class="title_left">
						    <custom:write name="onerow" property="tenderprice"   />
						    <custom:hidden name="onerow" property="tenderprice"   colIndex="<%=idx %>"/>
							<span class="red">*</span>
						</td> 
						<td class="title_left">
						    <custom:write name="onerow" property="historytenderprice" />
						    <custom:hidden name="onerow" property="historytenderprice"   colIndex="<%=idx %>"/>
						</td> 
						<td class="title_left">
						    <custom:write name="onerow" property="bidprice"   />
						    <custom:hidden name="onerow" property="bidprice"   colIndex="<%=idx %>"/>
						</td>
						<td class="title_left">
						    <custom:hidden name="onerow" property="ntsprice" colIndex="<%=idx %>" />
						    <custom:write name="onerow" property="rate" />
						    <custom:hidden name="onerow" property="rate" colIndex="<%=idx %>"/>
						    <custom:write name="onerow" property="percent" value="%"/>
						</td>  		
						
						<td class="title_left">
						    <custom:write name="onerow" property="comments"   />
						    <custom:hidden name="onerow" property="comments"   colIndex="<%=idx %>"/>
						</td>
						
										
		     	 </logic:iterate>
		     	 <!-- 
			<tr>
				 <td>&nbsp;</td>
				<td ><custom:hidden property="prodid" name="newhash" label="L_Product"  command="notnull"/> 
				     <custom:text property="prodcode" size="8" readonly="true" command="notnull" label="L_Product" name="newhash"/> 
					 <a onclick="javascript:frm_select(this,6);"><custom:button property="buttoner" type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a>
					 <span class="red">*</span> 
				</td>
				<td><custom:text property="prodname" size="30" readonly="true" name="newhash"/>
			    </td>
				<td><custom:selectdic name="newhash" property="istender" dictType="YesOrNo" valueCriteria="1-100" defaultValueCost=" "/></td>
				<td>
	               <custom:text property="tenderdate"  dataType="date"  module="IMG" size="15" name="newhash"/>
	             <a onclick="javascript:c.show(this,'cform.tenderdate','yyyy-MM-dd');"><custom:button type="3" label="L_Asterisk" imgsrc="Time.gif" border="0"/></a>
	            </td>
				<td>
	               <custom:text property="purchasebegindate"  dataType="date"  module="IMG" size="15" name="newhash"/>
	             <a onclick="javascript:c.show(this,'cform.purchasebegindate','yyyy-MM-dd');"><custom:button type="3" label="L_Asterisk" imgsrc="Time.gif" border="0"/></a>
	            </td>
				<td>
	               <custom:text property="purchaseenddate"  dataType="date"  module="IMG" size="15" name="newhash"/>
	             <a onclick="javascript:c.show(this,'cform.purchaseenddate','yyyy-MM-dd');"><custom:button type="3" label="L_Asterisk" imgsrc="Time.gif" border="0"/></a>
	            </td>	            			            											    		
				<td class="title_left">
				    <custom:text name="newhash" property="tenderprice"   size="15" />
					<span class="red">*</span>
				</td> 
				<td class="title_left">
				    <custom:text name="newhash" property="historytenderprice"  size="15" />
				</td> 
				<td class="title_left">
				    <custom:text name="newhash" property="bidprice"   size="15" />
				</td>
				<td class="title_left">
				    &nbsp;
				</td>
				<custom:hidden  property="distributortenderid" value="<%=distributortenderid%>" />
					
					
			 </tr>
		     	  -->
		      <%@ include file="/inc/SummaryAction.inc" %>
		      </table>	      
		      </td>
		      </tr>
		      <tr>
		      <td>
		      
		      <table width="100%" cellspacing="0" cellpadding="0">
		        <tr> 
		          <td class="summary_top"></td>
		        </tr>
		        <tr>
				     <td class="td_center">
						<a onclick="page_return()"><custom:button type="1" label="L_Back" border="0"  imgsrc="finish.gif" style="width:60" /></a>
					 </td>
				</tr>
		      </table>
		    </td>
	  </tr>
	</table>
</form>
</body>
</html>
